package com.zonski.jbots.desktop.editer.tool;

import com.zonski.jbots.desktop.editer.AbstractMouseTool;
import com.zonski.jbots.engine.Entity;

import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * Created by IntelliJ IDEA.
 * User: Chris Glover
 * Date: Oct 27, 2003
 * Time: 5:50:01 PM
 * To change this template use Options | File Templates.
 */
public class DeleteTool extends AbstractMouseTool
{
    public DeleteTool()
    {
    }

    public MouseListener createMouseListener()
    {
        return new DeleteMouseListener();
    }

    private class DeleteMouseListener extends MouseAdapter
    {
        public DeleteMouseListener()
        {

        }

        public void mousePressed(MouseEvent event)
        {
            Entity entity = getContext().getEntityAt(event.getX(), event.getY());
            if(entity != null)
            {
                getContext().getRoom().removeEntity(entity);
                getContext().getComponent().repaint();
            }
        }
    }
}
